<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>

<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
 
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">


function refresh(){
	location.reload();
}

//新增楼层页面
function addFloor(){
	top.addTempTab("/hotfloor/addhotproduct.do");
}

// 增加首页爆品
function addIndexFloor(){
	top.addTempTab("/hotfloor/index_hot_product.do");
}

//修改页面
$(function () {
	$(".button_modify").click(function(){
		var id = $(this).attr("data-id");
		top.addTempTab("/hotfloor/modify_hot_product.do?id="+id);
	});
});

//删除数据
function deleted(id){
	// 判断这个楼层的爆品有没有在首页
	$.getJSON("/hotfloor/is_hot_product_in_index.do", {floorId: id}, function(response){
		if (response.msg) {
			artDialog.confirm(response.msg + "，确认删除？", function(){
				// 如果有，提示确认后删除
				deleteFloor(id);
			});
		} else {
			artDialog.confirm("确认要删除该楼层？", function(){
				deleteFloor(id);
			});
		}
	});
}

function deleteFloor(id) {
	$.getJSON("/hotfloor/delete_floor.do", {floorId: id}, function(response){
		artDialog.alert("删除成功!", function(){
			refresh();
		});
	});
}



 </script>

</head>
<body>
    <div class="panel panel-info panel-content">
      <div class="panel-heading" style="position: relative;">
			
			<form id="soform" method="post">
				<div class="row">
					<div class="col-md-6">爆品首页</div>
					<div class="col-md-6 text-right">
						<input type="button" class="btn btn-info"   onclick="addFloor()"  value="添加爆品">
						<input type="button" class="btn btn-info"  onclick="addIndexFloor()" value="管理首页爆品">
					</div>
				</div>
				</form>		
		</div>
      
      <table class="table table-hover table-bordered table-striped table-condensed">
         <tr>
           <th>楼层名称</th>
           <th>所属类目</th>
           <th>更新时间</th>
           <th>操作</th>

         </tr>
         [#list floors as floor]
         <tr>
            <td align="center">${floor.floor!}</td>
            <td align="center">${floor.categoryName!}</td>
            <td align="center">${floor.updatetime!}</td>
            <td align="center">
            <input type="button" value="修改" data-id="${floor.id!}" class="btn btn-info  btn-xs button_modify" >
            <input type="button" value="删除" onclick="deleted('${floor.id!}')" class="btn btn-danger  btn-xs">
            </td>
         </tr>
         [/#list]
      </table>     
      </div>
</body>
</html>
